import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
// import  nanoid  from 'nanoid'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import "@/assets/iconfont/iconfont.css"
import * as echarts from 'echarts';
import NProgress from "nprogress";
import "nprogress/nprogress.css";
Vue.prototype.axios = axios
Vue.prototype.echarts = echarts
axios.defaults.baseURL = 'http://heima.9yuecloud.com:9988/api/private';



// vue table grid
import ZkTable from 'vue-table-with-tree-grid'
Vue.component(ZkTable.name, ZkTable)

// ele - ui
Vue.use(ElementUI);
// Vue.use(nanoid)

Vue.config.productionTip = false


// 添加请求拦截器
axios.interceptors.request.use(function (config) {
  // 在发送请求之前做些什么
  NProgress.start()   //请求时候开始显示进度条
  config.headers.Authorization = localStorage.getItem('token')
  return config;
}, function (error) {
  // 对请求错误做些什么
  return Promise.reject(error);
});

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
  // 对响应数据做点什么
  NProgress.done()
  return response;
}, function (error) {
  // 对响应错误做点什么
  return Promise.reject(error);
});


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
